package com.base.vo;

/**
 * 返回对象
 * @author Administrator
 * @param <T>
 */
@SuppressWarnings("serial")
public class Response<T> extends BaseVo {
    /**
     * 返回码
     */
    private int code;
    
    /**
     * 返回消息
     */
    private String message;
    
    /**
     * 返回数据集
     */
    private T data;
    
    public Response() {
        this.code = ReturnCodeEnum.CODE_0.getCode();
        this.message = ReturnCodeEnum.CODE_0.getMsg();
    }
    
    public Response(ReturnCodeEnum returnCode) {
        this.code = returnCode.getCode();
        this.message = returnCode.getMsg();
    }
    
    public Response(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public Response(ReturnCodeEnum returnCode, T data) {
        this.code = returnCode.getCode();
        this.message = returnCode.getMsg();
        this.data = data;
    }
    
    public Response(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    
    public Response(T data) {
        this.code = ReturnCodeEnum.CODE_0.getCode();
        this.message = ReturnCodeEnum.CODE_0.getMsg();
        this.data = data;
    }
    
    public boolean isSuccess() {
        return ReturnCodeEnum.CODE_0.getCode() == this.code;
    }
    
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public T getData() {
        return data;
    }
    
    public void setData(T data) {
        this.data = data;
    }
    
}
